<html>
<form name="input" action='summing_prototype.php' method="post">
Type of paper: <br /> 1 <input type="radio" name="pg_type_1" value="pg_type_1" /> <br />
2 <input type="radio" name="pg_type_2" value="pg_type_2" /> <br />
3 <input type="radio" name="pg_type_3" value="pg_type_3" /> <br />
Number of coloured pages: <input type='text' name="col_pg_no" size='12'  /> <br /> 
Stapled: <input type='checkbox' name="stapled" size='12'  /> <br />
Number of B&W pages: <input type='text' name="bw_pg_no" size='12'  /> <br />
<input type='submit' value='Submit' />
</form>
</html>

<?php
$pg_t = 0;
if(isset($_POST["pg_type_1"]))
$pg_t = 1;
if(isset($_POST["pg_type_2"]))
$pg_t = 2;
if(isset($_POST["pg_type_3"]))
$pg_t = 3;

echo "Your price is " . calculate($pg_t, $_POST["col_pg_no"], $_POST["bw_pg_no"], $_POST["stapled"]);

function calculate($pg_type, $col_pg_no, $bw_pg_no, $stapled)
{
	switch($pg_type)
	{
		case 1:
		$add_pg_type = 0.01;
		break;
		
		case 2:
		$add_pg_type = 0.03;
		break;
		
		case 3:
		$add_pg_type = 0.05;
		break;
		
		default: die("Error parsing input data.");
		break;
	}
	
	$pages = $col_pg_no + $bw_pg_no;
	$p1 = ($col_pg_no * 0.05) + ($bw_pg_no * 0.01);
	$p2 = $add_pg_type * $pages;
	$p3 = $stapled * $pages * 0.05;
	$price = $p1 + $p2 + $p3;
	
	return $price;
}
?>